package org.windowkit.toolkit.panel;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;

import org.windowkit.toolkit.frame.WindowLauncher;

/**
 *
 * @author Rich
 */
public abstract class AbstractPanel extends JPanel {

	/**
	 *
	 */
	private static final long serialVersionUID = 7721642703337217031L;
	private String title;
	private JInternalFrame parent;
	private WindowLauncher launcher;

	public AbstractPanel(final String title) {
		super(new BorderLayout());
		this.title = title;
		initComponents();
		add(createContents(), getLayoutPosition());
		addListeners();
	}

	protected String getLayoutPosition() {
		return BorderLayout.CENTER;
	}

	protected abstract void initComponents();
	protected void addListeners() {

	}

	protected abstract JComponent createContents();

	public Dimension requestDimesions() {
		return null;
	}

	public void setParent(final JInternalFrame parent) {
		this.parent = parent;
	}

	protected void setTitle(final String title) {
		this.title = title;
		if (parent != null) {
			parent.setTitle(title);
		}
	}

	public String getTitle() {
		return title;
	}

	public WindowLauncher getLauncher() {
		return launcher;
	}

	public void setLauncher(final WindowLauncher launcher) {
		this.launcher = launcher;
	}

}